home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 665 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: lyra.csx.cam.ac.uk!nmm1
  2. From: nmm1@cus.cam.ac.uk (Nick Maclaren)
  3. Newsgroups: comp.std.c
  4. Subject: Re: EXIT_SUCCES != EXIT_FAILURE?
  5. Date: 28 Mar 1996 10:52:05 GMT
  6. Organization: University of Cambridge, England
  7. Message-ID: <4jdr0l$ddn@lyra.csx.cam.ac.uk>
  8. References: <tompa.827763954@news> <4j7p4p$4n8@castle.nando.net>
  9. NNTP-Posting-Host: ursa.cus.cam.ac.uk
  10.  
  11. In article <4j7p4p$4n8@castle.nando.net>, actuary@nando.net   (Bill McCarthy) writes:
  12. |> In <tompa.827763954@news>, tompa@ida.liu.se (Thomas Padron-McCarthy) writes:
  13. |> >
  14. |> >Many of the students in a C course I teach have started to use
  15. |> >EXIT_SUCCESS and EXIT_FAILURE as return values from functions
  16. |> >(other than main).
  17. |> >
  18. |> >I don't like this new practice, but questions of style are difficult.
  19. |> >So I wonder: Does the standard guarantee that EXIT_SUCCESS and
  20. |> >EXIT_FAILURE are different?
  21. |> 
  22. |> Not only are they not guaranteed to be different.  EXIT_SUCCESS is
  23. |> not guaranteed to be zero, and EXIT_FAILURE is not guaranteed to
  24. |> be different from 0.  They are implementation defined and should
  25. |> only be used as an argument to exit() or in a return from main().
  26.  
  27. This is a little harsh.  While they are not defined to be different,
  28. they will be the same only on a very inferior implementation indeed!
  29. And few students are capable of writing code that can defend itself
  30. against such implementations.
  31.  
  32. Also, if they use them CONSISTENTLY, it doesn't matter that their
  33. values are not defined.  I would regard this practice as perfectly
  34. reasonable, in context, though I have no intention of adopting it
  35. myself.
  36.  
  37. To put things in context, do you expect all students to write code
  38. assuming the compilation and execution environments differ in their
  39. character sets and both fixed- and floating-point arithmetic?
  40.  
  41.  
  42. Nick Maclaren,
  43. University of Cambridge Computer Laboratory,
  44. New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
  45. Email:  nmm1@cam.ac.uk
  46. Tel.:  +44 1223 334761    Fax:  +44 1223 334679
  47.